<template>
    <a-modal :visible="isDown" title="数据导出" centered width="40%" :footer="null" destroyOnClose @cancel="cloFn">
        <div style="min-height: 350px">
            <a-row :gutter="[0,40]">
                <a-col :span="24">
                    <a-date-picker mode="year" :value="pickervalue" :open="isopen" @panelChange="panelChange" @openChange="handleOpenChange1" format="YYYY" :allowClear="false" placeholder="请选择导出年份" />
                </a-col>
                <a-col :span="6" v-for="v in buttonArr" :key="v.id">
                    <a-button type="primary" @click="DownLoasd(v)" style="min-width: 60%;">{{v.title}}</a-button>
                </a-col>
            </a-row>
        </div>
    </a-modal>
</template>

<script>
import moment from 'moment';
export default {
    data() {
        return {
            isDown: false,
            id: "",
            buttonArr:[{type:1,title:"小时"},{type:2,title:"天"},{type:3,title:"月"},{type:4,title:"年"},{type:5,title:"一季度"},{type:6,title:"二季度"},{type:7,title:"三季度"},{type:8,title:"四季度"}],
            pickervalue: moment(),
            isopen: false,
        };
    },
  props:{
    selectMN:{required:true,type:String,default:""}
  },
    methods: {
        panelChange(data) {
            this.pickervalue = data;
            this.isopen = false;
        },
        handleOpenChange1() {
            this.isopen = !this.isopen;
        },
        DownLoasd(item){
          console.log(this.selectMN,this.pickervalue.year())
          this.$api.reportFormDownLoadExcelOne(this.selectMN, item.type,this.pickervalue.year()).then((res) => {
            console.log(res.data)
            if (res.data.code == 0) {
              window.location.href = res.data.data;
            } else {
              this.$message.info("暂无数据导出");
            }
          });

        },
        init() {
            // this.$api.reportFormDownLoadExcelOne(this.id, this.pickervalue.year()).then((res) => {
            //     if (res.data.code == 0) {
            //         if(res.data.data != false){
            //             this.buttonArr = res.data.data
            //         }else {
            //             this.buttonArr = [];
            //             this.$message.info("暂无数据导出");
            //         }
            //     } else {
            //         this.$message.info("暂无数据导出");
            //     }
            // });
        },
        cloFn() {
            this.isDown = false;
            this.id = "";
            this.pickervalue = moment()
        },
    },
    watch:{
        // pickervalue:{
        //     deep:true,
        //     handler(){
        //         if(this.id != ""){
        //             this.init()
        //         }
        //     }
        // }
    },
    mounted() {},
};
</script>
<style lang="scss" scoped>
</style>